<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>个人信息</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand" />  
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">	
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">	
	<meta name="apple-mobile-web-app-status-bar-style" content="black">	
	<meta name="apple-mobile-web-app-capable" content="yes">	
	<meta name="format-detection" content="telephone=no">	
	<link rel="stylesheet" type="text/css" href="layui/css/layui.css" media="all">
	<link rel="stylesheet" type="text/css" href="js/bootstrap/css/bootstrap.css" media="all">
	<link rel="stylesheet" type="text/css" href="css/global.css" media="all">
	<link rel="stylesheet" type="text/css" href="css/personal.css" media="all">
</head>
<body>
<section class="layui-larry-box">
	<div class="larry-personal">
		<header class="larry-personal-tit">
			<span>用户信息</span>
		</header><!-- /header -->
		<div class="larry-personal-body clearfix">
			<form class="layui-form">
				<div class="layui-form-item">
					<label class="layui-form-label">用户名</label>
					<div class="layui-input-block">  
						<input type="text" name="userName"  id="userName"  autocomplete="off"  class="layui-input layui-disabled" value="admin" disabled="disabled" >
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">所属角色</label>
					<div class="layui-input-block">
						<input type="text" name="username"  autocomplete="off"  class="layui-input layui-disabled" value="超级管理员" disabled="disabled">
					</div>
				</div>
			</form>
			<form class="layui-form col-lg-5" action="" id="user-add" method="post">
				
				
				<div class="layui-form-item">
					<label class="layui-form-label">手机号码</label>
					<div class="layui-input-block">
						<input type="text" name="userPhone" id="userPhone" lay-verify="phone"  autocomplete="off" class="layui-input" placeholder="输入手机号码">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">用户邮箱</label>
					<div class="layui-input-block">
						<input type="text" name="userEmail" id="userEmail" lay-verify="email" autocomplete="off" class="layui-input" >
					</div>
				</div>
				<div class="layui-form-item">
				   <label class="layui-form-label">接收消息推送</label>
				    <div class="layui-input-block">
				        <input type="radio" name="jpushFlagStr" id="onjpushFlagStr" value="on" title="是">
						<input type="radio" name="jpushFlagStr" id="offjpushFlagStr" value="off" title="否" checked>
				    </div>
				</div>
				<div class="layui-form-item">
				   <label class="layui-form-label">接收报警短信</label>
				    <div class="layui-input-block">
				        <input type="radio" name="alarmFlagStr" id="on" value="on" title="是">
						<input type="radio" name="alarmFlagStr" id="off" value="off" title="否" checked>
				    </div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<div class="layui-btn" lay-submit="" id="button" lay-submit lay-filter="enterprise">立即提交</div>
					</div>
				</div>
			</form>
		</div>
	</div>
</section>
<script type="text/javascript" src="//cdn.bootcss.com/jquery/2.2.3/jquery.js"></script>
<script type="text/javascript" src="layui/layui.js"></script>
<script src="js/common.js"></script>
<script type="text/javascript">
	layui.use(['layer', 'form', 'util', 'element'], function() {
	var $ = layui.jquery,
		layer = layui.layer,
		element = layui.element(),
		util = layui.util;
		var form = layui.form();
	/**
	 * 使用内部工具组件
	 */
	util.fixbar();
	/**
	 ****************************jq扩展函数*******************************v**
	 */
	
	$.ajax({
		url :  url +'/ic-iot/users/'+adminId,
		type : 'get',
		dataType : 'json',
		contentType: "application/json; charset=utf-8",
		beforeSend: function(request) {
            request.setRequestHeader("accessToken", accessToken);
        },
		success : function(data) {
			if(data['code'] == 1){
				$("#userEmail").val(data.result.userEmail);
				$("#userName").val(data.result.userName);
				$("#userPhone").val(data.result.userPhone);
				if(data.result.alarmFlag == 1){
					$("#on").attr('checked','checked');
					form.render();
				}else{
					$("#off").attr('checked','checked');
					form.render();
				};
				if(data.result.jpushFlag == 1){
					$("#onjpushFlagStr").attr('checked','checked');
					form.render();
				}else{
					$("#offjpushFlagStr").attr('checked','checked');
					form.render();
				}
				
			}else{
				ifajax(data);
			}
			
       } 
	});
	
	form.on('submit(enterprise)', function(data){
		var data = formToJson($("#user-add"));
		$.ajax({
			url :  url +'/ic-iot/users/'+adminId,
			type : 'PUT',
			dataType : 'json',
			contentType: "application/json; charset=utf-8",
			data:data,
			beforeSend: function(request) {
	            request.setRequestHeader("accessToken", accessToken);
	        },
			success : function(data) {
				debugger;
				if(data['code'] == 1){
					layer.msg(data['description']);
				}else{
					ifajax(data);
				}
	       } 
		});
	   return false;
    });
});
	
	

</script>
</body>
</html>